

<!--/*--><root><![CDATA[<!--*/--> 

// See function from http://wiki.cdyne.com/wiki/index.php?title=Converting_XML_Timestamp_to_Javascript_Date
//2013-01-17T20:55:38Z
function ZuluTimeStampToDate(xmlDate)
{
  var dt = new Date();
  var dtS = xmlDate.slice(xmlDate.indexOf('T')+1, xmlDate.indexOf('.'))
  var TimeArray = dtS.split(":");
  dt.setUTCHours(TimeArray[0],TimeArray[1],TimeArray[2]);
  dtS = xmlDate.slice(0, xmlDate.indexOf('T'))
  TimeArray = dtS.split("-");
  dt.setUTCFullYear(TimeArray[0],TimeArray[1]-1,TimeArray[2]);
  return dt;
}

function parseXSDDateString(dateString) {
      var re = /(-)?(\d{4})-(\d{2})-(\d{2})(T(\d{2}):(\d{2}):(\d{2})(\.\d+)?)?(([\+-])((\d{2}):(\d{2})))?/;
      return eval(dateString.replace(re,'new Date(new Date(\'$3/$4/$2 $6:$7:$8 GMT$11$13$14\').getTime() + (1000 * 0$9))'));
}

// from Zvonko at http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_21889287.html
// DONT TRUST THIS ONE: does not respect local time zone offset?
function TimezonedTimeStampToDate(dateString) {
	
	var Zp=(dateString.charAt(10)=="T")?19:10;
	var xDate = new Date(dateString.substr(0,Zp).replace(/-/g,'/').replace("T"," "));
	if(dateString.length>Zp){
		xDate.setMinutes(xDate.getMinutes()+xDate.getTimezoneOffset());
		if(dateString.charAt(Zp)!="Z"){
			var tZ = dateString.substr(Zp).split(":");
			tZ=tZ[0]*60+(tZ[1]*1);
			xDate.setMinutes(xDate.getMinutes()+tZ);
		}
	}
	return xDate;
}



function TimeStampToDate(dateString) {
	if(dateString.indexOf('Z')!== -1 || dateString.indexOf('z')!== -1){
		return ZuluTimeStampToDate(dateString);
	}
	else{
	  return parseXSDDateString(dateString);
	}
}

function ConvertBattery(batteryString){
	return Math.round(parseFloat(batteryString) * 100.0);
}

function FormatPhone(phoneString){
	var phoneNumber = phoneString;
	
	if (phoneNumber.length == 11)
	{
		return phoneNumber.substring(0, 1) + "-" + phoneNumber.substring(1, 4) + "-" + phoneNumber.substring(4, 7) + "-" + phoneNumber.substring(7);
	}
	else if (phoneNumber.length == 10)
	{
		return phoneNumber.substring(0, 3) + "-" + phoneNumber.substring(3, 6) + "-" + phoneNumber.substring(6);
	}
	else if (phoneNumber.length == 7)
	{
		return phoneNumber.substring(0, 3) + "-" + phoneNumber.substring(3);
	}
	else
	{
		return phoneNumber;
	}
}

function FormatAddress(addressString){
	var address = addressString;
	
	return address.replace(",", "<br/>");
}
<!--/*-->]]></root><!--*/-->
